package com.fy.distributor.controller;


import com.fy.common.api.CommonResult;
import com.fy.common.util.BeansUtil;
import com.fy.distributor.vo.ProfitInputVo;
import com.fy.shop.api.DistributorService;
import com.fy.shop.dto.ProfitDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/show")
@Api(tags = "分销商利润管理")
@RefreshScope
public class DistributorProfitController {



    @Autowired
   private DistributorService distributorService;

    @ApiOperation("查询利润记录")
    @GetMapping(value = "/profitFindAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "distributorId", value = "分销商id"),
            @ApiImplicitParam(name = "type", value = "类型（个人，企业）"),
    })
    public CommonResult profitFindAll(@RequestBody ProfitInputVo profitInputVo)
        {
            ProfitDto profitDto = new ProfitDto();
            BeanUtils.copyProperties(profitInputVo,profitDto);
            List<ProfitDto> profitDtoList = distributorService.profitFindAll(profitDto);
            List<ProfitInputVo> profitInputVos = BeansUtil.listCopy(profitDtoList,ProfitInputVo.class);
            return CommonResult.success(profitInputVos);
    }
}
